home *** CD-ROM | disk | FTP | other *** search
- Path: nntp-trd.UNINETT.no!usenet
- From: frodeb@stud.idb.hist.no (Frode Breimo)
- Newsgroups: comp.lang.c++
- Subject: Q: Detecting keystrokes
- Date: Fri, 26 Jan 1996 17:07:51 GMT
- Organization: HiST
- Message-ID: <4eb1o9$4tf@doffen.uninett.no>
- NNTP-Posting-Host: pc164.idb.hist.no
- X-Newsreader: Forte Free Agent 1.0.82
-
- OK. This is probably a simple question but here goes:
-
- I've just started learning MS VC++ and want to write a DOS-program
- that reads the user's keystroke immediatley, without him having to
- press enter (and preferably without it even showing on the screen).
- This is meant to be a simple getkey program that reads a keystroke and
- uses it's ASCII-code as an exit-value for testing. I've tried several
- of the functions available, and even tried some of the examples
- provided in the help-files but nothing works. This is what I got so
- far:
-
- #include <iostream.h>
- #include <stdio.h>
- #include <bios.h>
-
- unsigned char Key; // The key pressed.
- int KeyCode; // The key's ASCII-code.
-
- void main(void)
- {
- // while( !(_bios_keybrd( _KEYBRD_SHIFTSTATUS ) & 0001) )
- // printf( "Use the right SHIFT key to stop this message\n" );
- // printf( "Right SHIFT key pressed\n" );
-
- Key = _bios_keybrd(_NKEYBRD_READ);
- cout << Key; // So far I'm just testing if the key was read
- correctly.
- }
-
- (The three lines with // in front of are from an example taken from
- the help-files. It didnt work.)
-
- This is what I get when I try to compile it:
-
- Compiling...
- x:\dokument\c\getkey.cpp
- x:\dokument\c\getkey.cpp(25) : error C2065: '_bios_keybrd' :
- undeclared identifier
- x:\dokument\c\getkey.cpp(25) : error C2064: term does not evaluate to
- a function
- CL returned error code 2.
- GETKEY.EXE - 2 error(s), 0 warning(s)
-
- Line 25 is where the call to the _bios_keybrd function is.
-
- Can someone please help me with this?
-
-
- ---------------------------------------------------------------
- Frode Breimo
- e-mail: frodeb@stud.idb.hist.no
- www: http://www.idb.hist.no/~frodeb
- ---------------------------------------------------------------
-
-